package com.example.test.chapter7.custom_listview_3_row;

import java.util.ArrayList;
import java.util.HashMap;

import com.example.test.R;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class CListViewActivity extends Activity {
	static final ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.clistview);
		SimpleAdapter adapter = new SimpleAdapter(this, list,
				R.layout.crowview, new String[] { "title", "author", "price" },
				new int[] { R.id.text1_custom_list_view_3_row,
						R.id.text2_custom_list_view_3_row,
						R.id.text3_custom_list_view_3_row });
		populateList();
		ListView listView = (ListView) findViewById(R.id.list_view_custom_list_view_3_row);
		listView.setAdapter(adapter);
	}

	private void populateList() {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("title", "Programming Android ");
		map.put("author", " Zigurd Mednieks..");
		map.put("price", "$44.99");
		list.add(map);
		
		map = new HashMap<String, String>();
		map.put("title",
				"The Android Developer's Cookbook: Building Applications with the Android SDK ");
		map.put("author", "James Steele and Nelson To ");
		map.put("price", "$44.99");
		list.add(map);
		
		map = new HashMap<String, String>();
		map.put("title", "Pro Android 3 ");
		map.put("author", "Satya Komatineni, Dave MacLean and Sayed Hashimi ");
		map.put("price", "$49.99");
		list.add(map);
		
		map = new HashMap<String, String>();
		map.put("title",
				"Beginning Android Application Development (Wrox Programmer to Programmer) ");
		map.put("author", "Wei Meng Lee");
		map.put("price", "$39.99");
		list.add(map);
		
		map = new HashMap<String, String>();
		map.put("title", "Learning Android");
		map.put("author", "Marko Gargenta");
		map.put("price", "$34.99");
		list.add(map);
		
		map = new HashMap<String, String>();
		map.put("title", "Android for Programmers: An App-Driven Approach");
		map.put("author", "Paul J. Deitel, Harvey M. Deitel, ...");
		map.put("price", "$44.99");
		list.add(map);
		
		map = new HashMap<String, String>();
		map.put("title",
				"Hello, Android: Introducing Google's Mobile Development Platform");
		map.put("author", " Ed Burnette");
		map.put("price", "$34.99");
		list.add(map);
		
		map = new HashMap<String, String>();
		map.put("title", "Beginning Android Games");
		map.put("author", "Mario Zechner");
		map.put("price", "$39.99");
		list.add(map);
	}
}
